#include <iostream>
using namespace std;

string mingwen="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string password;
string del(string str)
{
	for(int i=0;i<str.length();i++)
	{
		if(str[i]<='z'&&str[i]>='a') str[i]=str[i]-('a'-'A');
	}
	int pos=-1;
	for(int i=0;i<str.length();i++)
	{
		if(i+1>=str.length()) break;
		pos=str.find(str[i],i+1);
		while(i+1<str.length()&&pos!=string::npos)
		{
			str.erase(pos,1);
			pos=str.find(str[i],i+1);
		}
	}
	return str;
}

string getpassword(string str)
{
	for(int i=0;i<str.length();i++)
	{
		int pos;
		pos=mingwen.find(str[i]);
		if(pos==string::npos) continue;
		mingwen.erase(pos,1);
	}
	password=str+mingwen;
	return (str+mingwen);
}

void getres(string str)
{
	string answer;
	for(int i=0;i<str.length();i++)
	{
		if(str[i]>='A'&&str[i]<='Z')
		{
			answer=answer+password[(str[i]-'A')];
		}
		else if(str[i]>='a'&&str[i]<='z')
		{
			char t=str[i]-('a'-'A');
			t=password[(t-'A')]+('a'-'A');
			answer=answer+t;
		}
		else
		{
			answer=answer+str[i];
		}
	}
	cout<<answer<<endl;
}

int main()
{
	string str,ans;
	while(cin>>str>>ans)
	{
		str=del(str);
		getpassword(str);
		//cout<<password<<endl;
		getres(ans);
		mingwen="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		password.clear();
	}
	
	return 0;
} 
